const express=require("express");
const app=express();
const port=3001;
app.use(express.json());
app.use(express.urlencoded({extended:false}));

app.get("/:req_id",function(req,res){
    console.log(req.params);
    console.log(req.query);
    let str=`路由参数(params):${req.params.req_id}\n`;
    str+=`请求参数(query):${req.query.key1}\n`;
    res.send(str);
});
app.post("/",function(req,res){
    console.log(req.body);
    console.log(req.route);
    let str=`请求数据(body):${req.body.msg}\n`;
    str+=`${req.ip} -${req.url} -${req.route.path}`;
    res.send(str);
});
app.listen(port,function(){
    console.log(`MyApp访问地址:http://127.0.0.1:${port}`);
});